home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / perl5 / DateTime / Infinite.pm < prev    next >
Encoding:
Perl POD Document  |  2010-07-30  |  3.5 KB  |  167 lines

  1. package DateTime::Infinite;
  2. BEGIN {
  3.   $DateTime::Infinite::VERSION = '0.61';
  4. }
  5.  
  6. use strict;
  7. use warnings;
  8.  
  9. use DateTime;
  10. use DateTime::TimeZone;
  11.  
  12. use base qw(DateTime);
  13.  
  14. foreach my $m (qw( set set_time_zone truncate )) {
  15.     no strict 'refs';
  16.     *{"DateTime::Infinite::$m"} = sub { return $_[0] };
  17. }
  18.  
  19. sub is_finite   {0}
  20. sub is_infinite {1}
  21.  
  22. sub _rd2ymd {
  23.     return $_[2] ? ( $_[1] ) x 7 : ( $_[1] ) x 3;
  24. }
  25.  
  26. sub _seconds_as_components {
  27.     return ( $_[1] ) x 3;
  28. }
  29.  
  30. sub _stringify {
  31.     (
  32.         $_[0]->{utc_rd_days} == DateTime::INFINITY
  33.         ? DateTime::INFINITY . ''
  34.         : DateTime::NEG_INFINITY . ''
  35.     );
  36. }
  37.  
  38. sub STORABLE_freeze {return}
  39. sub STORABLE_thaw   {return}
  40.  
  41. package DateTime::Infinite::Future;
  42. BEGIN {
  43.   $DateTime::Infinite::Future::VERSION = '0.61';
  44. }
  45.  
  46. use base qw(DateTime::Infinite);
  47.  
  48. {
  49.     my $Pos = bless {
  50.         utc_rd_days   => DateTime::INFINITY,
  51.         utc_rd_secs   => DateTime::INFINITY,
  52.         local_rd_days => DateTime::INFINITY,
  53.         local_rd_secs => DateTime::INFINITY,
  54.         rd_nanosecs   => DateTime::INFINITY,
  55.         tz            => DateTime::TimeZone->new( name => 'floating' ),
  56.         },
  57.         __PACKAGE__;
  58.  
  59.     $Pos->_calc_utc_rd;
  60.     $Pos->_calc_local_rd;
  61.  
  62.     sub new {$Pos}
  63. }
  64.  
  65. package DateTime::Infinite::Past;
  66. BEGIN {
  67.   $DateTime::Infinite::Past::VERSION = '0.61';
  68. }
  69.  
  70. use base qw(DateTime::Infinite);
  71.  
  72. {
  73.     my $Neg = bless {
  74.         utc_rd_days   => DateTime::NEG_INFINITY,
  75.         utc_rd_secs   => DateTime::NEG_INFINITY,
  76.         local_rd_days => DateTime::NEG_INFINITY,
  77.         local_rd_secs => DateTime::NEG_INFINITY,
  78.         rd_nanosecs   => DateTime::NEG_INFINITY,
  79.         tz            => DateTime::TimeZone->new( name => 'floating' ),
  80.         },
  81.         __PACKAGE__;
  82.  
  83.     $Neg->_calc_utc_rd;
  84.     $Neg->_calc_local_rd;
  85.  
  86.     sub new {$Neg}
  87. }
  88.  
  89. 1;
  90.  
  91. # ABSTRACT: Infinite past and future DateTime objects
  92.  
  93.  
  94.  
  95. =pod
  96.  
  97. =head1 NAME
  98.  
  99. DateTime::Infinite - Infinite past and future DateTime objects
  100.  
  101. =head1 VERSION
  102.  
  103. version 0.61
  104.  
  105. =head1 SYNOPSIS
  106.  
  107.   my $future = DateTime::Infinite::Future->new;
  108.   my $past   = DateTime::Infinite::Past->new;
  109.  
  110. =head1 DESCRIPTION
  111.  
  112. This module provides two L<DateTime.pm|DateTime> subclasses,
  113. C<DateTime::Infinite::Future> and C<DateTime::Infinite::Past>.
  114.  
  115. The objects are in the "floating" timezone, and this cannot be
  116. changed.
  117.  
  118. =head1 BUGS
  119.  
  120. There seem to be lots of problems when dealing with infinite numbers
  121. on Win32.  This may be a problem with this code, Perl, or Win32's IEEE
  122. math implementation.  Either way, the module may not be well-behaved
  123. on Win32 operating systems.
  124.  
  125. =head1 METHODS
  126.  
  127. The only constructor for these two classes is the C<new()> method, as
  128. shown in the L<SYNOPSIS|/SYNOPSIS>.  This method takes no parameters.
  129.  
  130. All "get" methods in this module simply return infinity, positive or
  131. negative.  If the method is expected to return a string, it return the
  132. string representation of positive or negative infinity used by your
  133. system.  For example, on my system calling C<year()> returns a number
  134. which when printed appears either "inf" or "-inf".
  135.  
  136. The object is not mutable, so the C<set()>, C<set_time_zone()>, and
  137. C<truncate()> methods are all do-nothing methods that simply return
  138. the object they are called with.
  139.  
  140. Obviously, the C<is_finite()> method returns false and the
  141. C<is_infinite()> method returns true.
  142.  
  143. =head1 SEE ALSO
  144.  
  145. datetime@perl.org mailing list
  146.  
  147. http://datetime.perl.org/
  148.  
  149. =head1 AUTHOR
  150.  
  151. Dave Rolsky <autarch@urth.org>
  152.  
  153. =head1 COPYRIGHT AND LICENSE
  154.  
  155. This software is Copyright (c) 2010 by Dave Rolsky.
  156.  
  157. This is free software, licensed under:
  158.  
  159.   The Artistic License 2.0
  160.  
  161. =cut
  162.  
  163.  
  164. __END__
  165.  
  166.  
  167.